package com.monitor.service.impl;

import com.monitor.dao.MessageDao;
import com.monitor.dao.UserDao;
import com.monitor.po.Message;
import com.monitor.po.User;
import com.monitor.service.MessageService;
import com.monitor.util.Pager;

public class MessageServiceImpl implements MessageService {
	private MessageDao messageDao;
	private UserDao userDao;

	@Override
	public Pager<Message> getMessagesByUid(long uid, int pageSize, int currentPage) throws Exception {
		User user = userDao.getUserById(uid);
		if (user == null)
			return null;
		return messageDao.getMessageByPhone(user.getPhone(), pageSize, currentPage);
	}

	@Override
	public boolean deleteMessage(long uid, long mid) throws Exception {
		User user = userDao.getUserById(uid);
		if (user == null)
			return false;
		return messageDao.deleteMessage(mid, user.getPhone()) > 0;
	}
	public MessageDao getMessageDao() {
		return messageDao;
	}

	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}

	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

}
